package com.sinoyd.itszyw.Adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.sinoyd.itszyw.Model.RepairsDepInfo;
import com.sinoyd.itszyw.R;

import org.xutils.view.annotation.ViewInject;
import org.xutils.x;

import java.util.List;

/**
 * @createBy : dbz 大饼洲
 * @description :
 * @projectName : ITYW
 * @creationDate: 2017-05-17 14:48
 */
public class MaintainRepairsDepAdapter extends BaseAdapter {

    private List<RepairsDepInfo> repairsDepList;
    private Context mContext;
    private LayoutInflater mLayoutInflater;

    public MaintainRepairsDepAdapter(Context context, List<RepairsDepInfo> list){
        this.mContext = context;
        this.repairsDepList = list;
        mLayoutInflater = LayoutInflater.from(mContext);

    }

    private class viewHolder {
        @ViewInject(R.id.repairs_dep_name)
        TextView repairs_dep_name;


    }


    @Override
    public int getCount() {
        return repairsDepList == null ? 0 : repairsDepList.size();
    }

    @Override
    public Object getItem(int position) {
        return repairsDepList.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        viewHolder cellHolder = null;

        if (convertView == null) {
            cellHolder = new viewHolder();
            convertView = mLayoutInflater.inflate(R.layout.listview_repairs_dep, null);
            x.view().inject(cellHolder, convertView);
            convertView.setTag(cellHolder);
        } else {
            cellHolder = (viewHolder) convertView.getTag();
        }
        RepairsDepInfo repairsDepInfo = repairsDepList.get(position);
        cellHolder.repairs_dep_name.setText(repairsDepInfo.repairsDepName);
//        cellHolder.repairs_d.setText(RepairsInfo.repairsName);
//        cellHolder.repairs_b.setText(RepairsInfo.repairsName);

        return  convertView;
    }
}
